Skip to content

fix(state-pg): setIfNotExists TTL expiry#636

Merged
bensabic merged 2 commits into
vercel:mainfrom
Zygimantass:codex/state-pg-set-if-not-exists-ttl
Jul 15, 2026
Merged

fix(state-pg): setIfNotExists TTL expiry#636
bensabic merged 2 commits into
vercel:mainfrom
Zygimantass:codex/state-pg-set-if-not-exists-ttl

Conversation

@Zygimantass

Copy link
Copy Markdown
Contributor

Summary

Fixes the Postgres state adapter so setIfNotExists() can claim a cache key whose existing row has expired.

Previously the method used ON CONFLICT DO NOTHING, so an expired row in chat_state_cache still blocked acquisition until a separate cleanup deleted it. That diverged from the memory adapter behavior and from the expected lease semantics for cache-backed coordination.

The new query keeps active rows protected, but replaces rows whose expires_at is in the past.

Validation

  • pnpm --filter @chat-adapter/state-pg test
  • pnpm --filter @chat-adapter/state-pg typecheck
  • pnpm exec ultracite check packages/state-pg/src/index.ts packages/state-pg/src/index.test.ts

@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

@Zygimantass is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@bensabic
bensabic force-pushed the codex/state-pg-set-if-not-exists-ttl branch from d973328 to 0870b6d Compare July 15, 2026 03:05
@bensabic
bensabic marked this pull request as ready for review July 15, 2026 03:06
@bensabic
bensabic requested a review from a team as a code owner July 15, 2026 03:06
@bensabic bensabic changed the title [codex] fix state-pg setIfNotExists TTL expiry fix(state-pg): setIfNotExists TTL expiry Jul 15, 2026
@bensabic
bensabic merged commit d88789c into vercel:main Jul 15, 2026
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants